﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;

namespace DataPreperation
{
    class Program
    {
        static void Main(string[] args)
        {
            List<IItem> items = CreateItems();
            DBGenerator dbgen = new DBGenerator();

            dbgen.GenerateDB(items);

            GradedDB db = DeSerializeDB("SerializedDB.bin");

        }


        public static List<IItem> CreateItems()
        {
            List<IItem> toReturn = new List<IItem>();

            toReturn.Add( new document("1111",2,"fish cat football apple ipod"));
            toReturn.Add( new document("3333",3,"cow horse football apple ipod"));
            toReturn.Add( new document("4444",5,"elazar dream test grade"));

            return toReturn;
        }

        public static GradedDB DeSerializeDB(string fileName)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
            GradedDB db = (GradedDB)formatter.Deserialize(stream);
            stream.Close();

            return db;
        }
    }



    [Serializable]
    class document : IItem
    {
        string _id;
        string _text;
        double _tmscore;

        public document(string id, double tmscore, string text)
        {
            _id = id;
            _text = text;
            _tmscore = tmscore;
        }

        public string GetText() // returns the item's text
        {
            return _text;
        }

        public string GetID()   // returns the item's ID
        {
            return _id;
        }

        public double getTMScore()  // returns the item's TMScore
        {
            return _tmscore;
        }
 
    }
}
